//
//  XUSanFirstController.m
//  新浪微博
//
//  Created by xuwenxin on 15-4-9.
//  Copyright (c) 2015年 xuwenxin. All rights reserved.
//

#import "XUSanFirstController.h"

@interface XUSanFirstController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *LayoutY;
@property (nonatomic, strong) CADisplayLink *link;

@end

@implementation XUSanFirstController
- (IBAction)close:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
    [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    self.link = link;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.link.paused = NO;
}
- (void)update{
    self.LayoutY.constant += 2;
    if (self.LayoutY.constant == 170) {
        self.LayoutY.constant = -170;
    }
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    self.link.paused = YES;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
